<meta charset="utf-8">
<style>

        .lay-box{
            border: 1px #dfdfdf solid;
            width: 98%;
            height: 95%;
            margin: 0 auto;
            padding-top: 1rem;
        }
        .lay-box .lay-content{
            width: 40%;
            margin-left: 20%;
            height: 2rem;
        }
        .lef{
            width: 25%;
            text-align: right;
            float: left;
        }
        .lay-box .lay-content .lay-span{
            font-size: 0.2rem;
            color: #a4a4a4;
            text-align: right;
        }
        .lay-box .lay-content .rig{
            float: right;
            width: 75%;
        }
        select{
            border: 1px solid #9F9F9F;
            font-size: 0.7rem;
            padding: 0.25rem 0.4rem;
            margin-left: 0.2rem;
            color: black;
            width: 82%;
            outline:none;
        }
        .lay-box .lay-content .rig .lay-input-text{
            border: 1px solid #9F9F9F;
            font-size: 0.7rem;
            padding: 0.28rem 0.4rem;
            margin-left: 0.2rem;
            color: black;
            outline:none;
            border-radius: 1px;
        }
        .lay-box .lay-content .rig .lay-submit{
            background: #01AAED;
            padding: 0.5rem 3rem;
            color: white;
            border-radius: 6px;
            margin-top: 1.2rem;
            outline:none;
            border: none;
        }

    </style>
<div class="lay-box">

    <div class="lay-content">
        <div class="lef">
            <span class="lay-span">手机：</span>
        </div>
        <div class="rig">
            <input type="text" name="mobile" disabled="disabled" value="{$user['mobile']}" class="lay-input-text"><br>
        </div>
    </div>
    <div class="lay-content">
        <div class="lef">
            <span class="lay-span">姓名：</span>
        </div>
        <div class="rig">
            <input type="text" name="name" value="{$user['name']}" class="lay-input-text"><br>
        </div>
    </div>
    <div class="lay-content">
        <div class="lef">
            <span class="lay-span">岗位：</span>
        </div>
        <div class="rig">
            <select name="group_id">
                <option value="0">请选择</option>
                {volist name="group" id='vo'}
                <option value="{$vo.id}" {if condition="$vo.id == $user.id"} selected {/if}>{$vo.title}</option>
                {/volist}
            </select>
        </div>
    </div>
    <div class="lay-content">
        <div class="lef">
            <span class="lay-span">限制IP：</span>
        </div>
        <div class="rig">
            <input type="text" name="limit_ip" value="{$user['limit_ip']}" class="lay-input-text"><br>
        </div>
    </div>
    <div class="lay-content">
        <div class="lef">
            <span class="lay-span">年龄：</span>
        </div>
        <div class="rig">
            <input type="text" name="age" value="{$user['age']}" class="lay-input-text" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"><br>
        </div>
    </div>
    <div class="lay-content">
        <div class="lef">
            <span class="lay-span">QQ：</span>
        </div>
        <div class="rig">
            <input type="text" name="qq" value="{$user['qq']}" class="lay-input-text" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"><br>
        </div>
    </div>
    <div class="lay-content">
        <div class="lef">
            <span class="lay-span">微信：</span>
        </div>
        <div class="rig">
            <input type="hidden" name="id" value="{$user['id']}">
            <input type="text" name="wechat" value="{$user['wechat']}" class="lay-input-text"><br>
            <input type="submit" value="提交" onclick="btnEditUser()" class="lay-submit">
        </div>
    </div>
</div>
<script src="/resource/libs/jquery/jquery.js"></script>
<script src="/static/js/layer/layer.js"></script>
<script type="text/javascript">
    function btnEditUser(){
        var id = $("input[name=id]").val();
        var name = $("input[name=name]").val();
        var group_id = $("select[name=group_id]").val();
        var limit_ip = $("input[name=limit_ip]").val();
        var age = $("input[name=age]").val();
        var qq = $("input[name=qq]").val();
        var wechat = $("input[name=wechat]").val();
        if(!$.trim(name)) {
            layer.msg('请输入姓名');
            return false;
        }
        if( $.trim(limit_ip) && checkIP($.trim(limit_ip)) == false) {
            layer.msg('ip格式错误');
            return false;
        }
        $.post('/index/user/edit',{id:id,name:name,group_id:group_id,limit_ip:limit_ip,age:age,qq:qq,wechat:wechat},function(res){
            layer.msg(res.msg);
            if(res.code == 1){
                window.setTimeout(function(){
                    window.parent.location.reload();
                },1000);
            }
        });
    }
    //判断ip地址的合法性
    function checkIP(value){
        var exp=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
        var reg = value.match(exp);
        if(reg==null)
        {
        return false;
        }
    }
</script>